package com.eastfair.venuebooking.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.eastfair.annotation.annotation.vo.VoInfo;
import com.eastfair.venuebooking.demand.ContractManageGroup;
import com.eastfair.venuebooking.enumeration.ContractManageContractStatusEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * The type Contract manage vo.
 *
 * @author dqq
 * @date 2022 /6/24
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@Accessors(chain = true)
public class ContractManageVO implements Serializable {

    private static final long serialVersionUID = 1L;

    private Map<String, Object> echoMap = new HashMap<>();

    /**
     * 主键IS
     */
    @VoInfo(groups = {ContractManageGroup.queryContractManageById.class, ContractManageGroup.QueryContract.class})
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long id;

    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    private Integer isEnabled;


    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 归属人员部门id
     */
    @ApiModelProperty(value = "归属人员部门id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    private Long orgCode;
    /**
     * 归属人员部门名称
     */
    @ApiModelProperty(value = "归属人员部门名称")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    private String orgName;
    /**
     * 前归属部门
     */
    @ApiModelProperty(value = "前归属部门")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long lastOrgCode;

    /**
     * 前归属部门名称
     */
    @ApiModelProperty(value = "前归属部门名称")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String lastOrgName;

    /**
     * 归属人员
     */
    @ApiModelProperty(value = "归属人员")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "归属人员")
    private Long belongTo;

    /**
     * 归属人姓名
     */
    @ApiModelProperty(value = "归属人姓名")
    @Size(max = 255, message = "归属人姓名长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "归属人姓名")
    private String belongToName;

    /**
     * 前归属人id
     */
    @ApiModelProperty(value = "前归属人id")
    @TableField(value = "last_belong_to")
    @Excel(name = "前归属人id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long lastBelongTo;

    /**
     * 前归属人id姓名
     */
    @ApiModelProperty(value = "前归属人id姓名")
    @Size(max = 255, message = "前归属人id姓名长度不能超过255")
    @TableField(value = "last_belong_to_name", condition = LIKE)
    @Excel(name = "前归属人id姓名")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String lastBelongToName;

    /**
     * 合同编号
     */
    @ApiModelProperty(value = "合同编号")
    @Size(max = 20, message = "合同编号长度不能超过20")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "合同编号")
    private String contractNumber;

    /**
     * 合同名称
     */
    @ApiModelProperty(value = "合同名称")
    @Size(max = 50, message = "合同名称长度不能超过50")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "合同名称")
    private String contractName;

    /**
     * 展会id
     */
    @ApiModelProperty(value = "展会id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "展会id")
    private Long exhibitionId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 255, message = "展会名称长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "展会名称")
    private String exhibitionName;

    /**
     * 合同付款状态
     */
    @ApiModelProperty(value = "合同付款状态")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "合同付款状态")
    private String contractPayState;

    /**
     * 合同金额
     */
    @ApiModelProperty(value = "合同金额")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "合同金额")
    private BigDecimal contractAmount;

    /**
     * 合同回款金额
     */
    @ApiModelProperty(value = "合同回款金额")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "合同回款金额")
    private BigDecimal contractReturndAmount;

    /**
     * 商机id
     */
    @ApiModelProperty(value = "商机id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "商机id")
    private Long opportunityId;

    /**
     * 报价书id
     */
    @ApiModelProperty(value = "报价书id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "报价书id")
    private Long quotationId;

    @ApiModelProperty(value = "报价书标题")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "报价书标题")
    private String quotationTitle;

    /**
     * 模板id
     */
    @ApiModelProperty(value = "模板id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "模板id")
    private Long contractTemplateId;

    /**
     * 合同模板名称
     */
    @ApiModelProperty(value = "合同模板名称")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String contractTemplateName;

    /**
     * 乙方id(按客户名称查询如库里有则不为空)
     */
    @ApiModelProperty(value = "乙方id(按客户名称查询如库里有则不为空)")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "乙方id(按客户名称查询如库里有则不为空)")
    private Long cutomerId;

    /**
     * 乙方名称
     */
    @ApiModelProperty(value = "乙方名称")
    @Size(max = 255, message = "乙方名称长度不能超过255")
    @VoInfo(groups = {ContractManageGroup.queryContractManageById.class, ContractManageGroup.QueryContract.class})
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "乙方名称")
    private String cutomerName;

    /**
     * 乙方法人代表
     */
    @ApiModelProperty(value = "乙方法人代表")
    @Size(max = 255, message = "乙方法人代表长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "乙方法人代表")
    private String customerLegal;

    /**
     * 乙方统一代码
     */
    @ApiModelProperty(value = "乙方统一代码")
    @Size(max = 20, message = "乙方统一代码长度不能超过20")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "乙方统一代码")
    private String customerUscc;

    /**
     * 乙方地址
     */
    @ApiModelProperty(value = "乙方地址")
    @Size(max = 255, message = "乙方地址长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "乙方地址")
    private String customerAddress;

    /**
     * 主办
     */
    @ApiModelProperty(value = "主办")
    @Size(max = 255, message = "主办长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "主办")
    private String sponsorName;

    /**
     * 协办
     */
    @ApiModelProperty(value = "协办")
    @Size(max = 255, message = "协办长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "协办")
    private String undertakerName;

    /**
     * 开始时间
     */
    @ApiModelProperty(value = "开始时间")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @ApiModelProperty(value = "结束时间")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime endTime;

    /**
     * 签单日期
     */
    @ApiModelProperty(value = "签单日期")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "签单日期", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime signingTime;

    /**
     * 我方签单人
     */
    @ApiModelProperty(value = "我方签单人")
    @Size(max = 255, message = "我方签单人长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "我方签单人")
    private String signatoryName;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Size(max = 255, message = "备注长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "备注")
    private String remark;

    /**
     * 合同url
     */
    @ApiModelProperty(value = "合同url")
    @Size(max = 255, message = "合同url长度不能超过255")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "合同url")
    private String contractUrl;

    /**
     * 场地保证金
     */
    @ApiModelProperty(value = "场地保证金")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "场地保证金")
    private BigDecimal spaceBond;

    /**
     * 服务预存款
     */
    @ApiModelProperty(value = "服务预存款")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Excel(name = "服务预存款")
    private BigDecimal serviceBond;

    /**
     * 已开票金额
     */
    @ApiModelProperty(value = "已开票金额")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @Excel(name = "已开票金额")
    private BigDecimal invoicedAmount;

    /**
     * 可开票金额
     */
    @VoInfo(groups = {ContractManageGroup.queryContractManageById.class, ContractManageGroup.QueryContract.class})
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private BigDecimal sureInvoicedAmount;

    /**
     * 合同状态 #{SUBMIT:待审核;APPROVED:已审核;CANCEL:已作废}
     */
    @ApiModelProperty(value = "合同状态 #{SUBMIT:待审核;APPROVED:已审核;CANCEL:已作废}")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private ContractManageContractStatusEnum contractStatus;

    /**
     * 支付计划列表
     */
    @ApiModelProperty(value = "支付计划列表")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<PayApiPaymentPlanVO> paymentPlanList;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    protected LocalDateTime updateTime;
    /**
     * 合同财务信息
     */
    @ApiModelProperty(value = "合同财务信息")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PayApiContractFinanceVO contractFinance;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long createdBy;
    /**
     * 创建人姓名
     */
    @ApiModelProperty(value = "创建人姓名")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String createdByName;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @VoInfo(groups = {ContractManageGroup.QueryContract.class})
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private LocalDateTime createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long updatedBy;
    /**
     * 更新人姓名
     */
    @ApiModelProperty(value = "更新人姓名")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String updatedByName;

    /**
     * 最后跟进时间
     */
    @ApiModelProperty(value = "最后跟进时间")
    @TableField(value = "last_follow_date")
    @Excel(name = "最后跟进时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private LocalDateTime lastFollowDate;

    /**
     * 下次跟进时间
     */
    @ApiModelProperty(value = "下次跟进时间")
    @TableField(value = "next_follow_date")
    @Excel(name = "下次跟进时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private LocalDateTime nextFollowDate;

    /**
     * 场地费用
     */
    @ApiModelProperty(value = "场地费用")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private BigDecimal spaceAmount;

    /**
     * 场地数量
     */
    @ApiModelProperty(value = "场地数量")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer spaceNum;
}
